package indi.kider.server.appclient.service.related;

import indi.kider.common.model.apabus.Rent;
import indi.kider.common.model.employee.AppUser;
import indi.kider.common.model.employee.Tenant;
import indi.kider.common.model.employee.User;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;
import pers.vankid.common.model.base.CommonResponse;

import java.util.List;

/**
 * Created by shixj on 2018/1/3.
 */
@FeignClient(value = "human-resources")
public interface TenantService {
    @GetMapping(value = "tenant/rent/{key}")
    CommonResponse<Rent> getTenantRent(@PathVariable(value = "key") String key);

    @PostMapping("tenant/friend")
    CommonResponse addFriend(@RequestBody Tenant tenant);

    @GetMapping("tenant/{mainId}/friend")
    CommonResponse<List<Tenant>> getTenants(@PathVariable(value ="mainId" ) Long mainId);

    /**
     * @api {GET} /user/app-user/{key}/{role}
     * @apiGroup employee
     * @apiDescription 根据key获取用户信息 type;1:房客2:房东3:房客邀请的好友4：服务人员5：工人
     * @apiParamExample 请求样例：
     * http://localhost:9002/human-resources/user/app-user/18013897594
     * @apiSuccessExample {json} 返回样例:
     * {"status":"200","msg":"查询成功！","data":{"type":1,"appUser":{"id":69,"name":"wbb","cardId":"44","phone":"13333333333","title":null,"nationality":null,"professional":null,"wxopenId":null,"state":2,"type":null,"friendsSize":3,"mainId":null},"relatedUser":null,"rent":{"id":105,"housesId":82,"communityId":15,"tenantId":69,"rentDate":"2018-05-28","state":1,"remark":"44","priceSet":1100.0,"setLease":1,"leaseType":null,"deposit":1000.0,"depositRemark":null,"initWaterReading":10.0,"initPowerReading":10.0,"payCycle":1,"wxopenId":null,"tenantName":"wbb","tenantTel":"13333333333","houseNumb":"WN_0005","building":null,"unit":null,"address":"日日鲁嘻嘻","community":"日日公寓","cardId":"44","netCost":2.0,"propertyCosts":2.0,"powerCost":10.0,"waterCost":10.0,"gasCost":null,"nationality":null,"professional":null,"friendsSize":1}}}
     * {"status":"200","msg":"查询成功！","data":{"type":1,"appUser":{"id":1,"name":"shixj","cardId":12212,"phone":"1221","nationality":"32","professional":"23","wxopenId":"121","title":null}}}
     */
    @GetMapping("user/app-user/{key}/{role}")
    CommonResponse<AppUser> getAppuserByKey(@PathVariable (value = "key")String key, @PathVariable  (value = "role")Integer role);

    /**
     * @api {POST} /user/app-user
     * @apiGroup employee
     * @apiDescription 登陆校验 如单角色直接返回AppUser ，否则返回 type为0，appUser.role 为角色数组字符串例1,3,4
     * @apiParamExample 请求样例：
     * http://localhost:9002/human-resources/user/app-user
     * {"phone":12121,"pwd":"qweqw"}
     * @apiSuccessExample {json} 返回样例:
     * {"status":"200","msg":"查询成功！","data":{"type":1,"appUser":{"id":69,"name":"wbb","cardId":"44","phone":"13333333333","title":null,"nationality":null,"professional":null,"wxopenId":null,"state":2,"type":null,"friendsSize":3,"mainId":null},"relatedUser":null,"rent":{"id":105,"housesId":82,"communityId":15,"tenantId":69,"rentDate":"2018-05-28","state":1,"remark":"44","priceSet":1100.0,"setLease":1,"leaseType":null,"deposit":1000.0,"depositRemark":null,"initWaterReading":10.0,"initPowerReading":10.0,"payCycle":1,"wxopenId":null,"tenantName":"wbb","tenantTel":"13333333333","houseNumb":"WN_0005","building":null,"unit":null,"address":"日日鲁嘻嘻","community":"日日公寓","cardId":"44","netCost":2.0,"propertyCosts":2.0,"powerCost":10.0,"waterCost":10.0,"gasCost":null,"nationality":null,"professional":null,"friendsSize":1}}}
     * {"status":"200","msg":"查询成功！","data":{"type":1,"appUser":{"id":1,"name":"shixj","cardId":12212,"phone":"1221","nationality":"32","professional":"23","wxopenId":"121","title":null}}}
     */
    @PostMapping("user/app-user")
    CommonResponse<AppUser> login(@RequestBody User user);
    /**
     * @api {POST} /user/app-user
     * @apiGroup employee
     * @apiDescription 修改密码
     * @apiParamExample 请求样例：
     * http://localhost:9002/human-resources/user/app-user
     * {"phone":12121,"pwd":"qweqw","newPwd":"1231231"}
     * @apiSuccessExample {json} 返回样例:
     * {"status":"202","msg":"保存成功！","data":""}
     */
    @PutMapping("user/app-user")
    CommonResponse<String> modify(@RequestBody User user);
}
